/***************************************************************************
 *   Copyright (C) 2009 by Marcin Swiechowicz   *
 *   marcin.swiechowicz@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef KDCSUBTITLEMODEL_H
#define KDCSUBTITLEMODEL_H

#include <QAbstractTableModel>
#include <QList>

#include <kdcmovie.h>

class KDCSubtitleModel : public QAbstractTableModel
{
Q_OBJECT
public:
	enum ModelRole { MovieTitleRowRole = Qt::UserRole + 1 }; 
	KDCSubtitleModel( QObject *aParent = 0 );
	~KDCSubtitleModel();
	
	int rowCount( const QModelIndex &aParent = QModelIndex() ) const;
    QVariant data( const QModelIndex &aIndex, int aRole = Qt::DisplayRole ) const;
	bool setData( const QModelIndex &aIndex, const QVariant &aValue, int aRole = Qt::EditRole );
    QModelIndex parent( const QModelIndex &aIndex ) const;
    int columnCount( const QModelIndex &aParent = QModelIndex() ) const;
    Qt::ItemFlags flags(const QModelIndex &aIndex ) const;
    QVariant headerData( int aSection, Qt::Orientation aOrientation, int aRole = Qt::DisplayRole ) const;
	QStringList mimeTypes() const;
	Qt::DropActions supportedDropActions() const;
	QMimeData* mimeData( const QModelIndexList &aIndexes ) const;
	bool dropMimeData( const QMimeData *aData, Qt::DropAction aAction, int aRow, int aColumn, const QModelIndex &aParent );

	void setMovie( KDCMovie *aMovie );
	void removeSubtitle( int aRow );
	void addSubtitle( KDCMovie *aMovie, Subtitle *aSubtitle );
	
	int movieFromRow( int aRow ) const;
	int movieTitleRow( int aMovieIdx ) const;
	QList<int> titleRows() const;
signals:
	void endTitleRowsChanged();
	void beginTitleRowsChanged();
protected:
	QList<int> movieSubtitleRows( int aMovieIdx ) const;
private:
	QList<KDCMovie*> pMovies;
};
#endif
